package com.AAA.service.Impl.fpa;

import com.AAA.dao.fpa.ITFpaRecordMapper;
import com.AAA.entity.MyPage;
import com.AAA.entity.fpa.TFpaRecord;
import com.AAA.entity.fpa.TjMessage;
import com.AAA.entity.fpa.Ttongji;
import com.AAA.entity.sas.TSasRecordjieguo;
import com.AAA.entity.sas.TSasRecordren;
import com.AAA.service.fpa.TFpaRecordService;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * (TFpaRecord)表服务实现类
 *
 * @author 何泽明
 * @since 2022-11-05 17:00:39
 */
@Service
public class TFpaRecordServiceImpl implements TFpaRecordService {
   @Autowired
   private ITFpaRecordMapper mapper;

   @Override
   public TFpaRecord checkRecord(TFpaRecord record) {
      TFpaRecord tFpaRecord = mapper.selectOne(record);
      return tFpaRecord;
   }

   @Override
   public int insertRecord(TFpaRecord record) {
      record.setCreatetime(new Date());
      int i = mapper.insert(record);
      System.out.println(record.getId());
      return record.getId();
   }

   @Override
   public PageInfo getAll(MyPage myPage, TFpaRecord record) {
      PageHelper.startPage(myPage.getPage(), myPage.getLimit());
      Example example = new Example(TFpaRecord.class);
      if(record.getUsername()!=null){
         example.createCriteria().andLike("username",record.getUsername());
      }
      example.setOrderByClause("createtime desc");
      List<TFpaRecord> select = mapper.selectByExample(example);
      PageInfo pageInfo = new PageInfo(select);
      return pageInfo;
   }

   @Override
   public PageInfo getDetailMsg(Integer id, MyPage myPage) {
      PageHelper.startPage(myPage.getPage(), myPage.getLimit());
      List<Map<String,Object>> details = mapper.getDetails(id);
      PageInfo pageInfo = new PageInfo(details);
      return pageInfo;
   }

   @Override
   public List<Ttongji> getTjData() {
      return mapper.getTjData();
   }

   @Override
   public PageInfo getTjData2(MyPage myPage, TjMessage tjMessage) {
      PageHelper.startPage(myPage.getPage(),myPage.getLimit());
      return new PageInfo(mapper.getTjData2(tjMessage));
   }

}

